package com.zt.chatgpt.openai.model.aggregates;

import com.zt.chatgpt.openai.model.entity.MessageEntity;
import com.zt.chatgpt.types.common.Constants;
import com.zt.chatgpt.types.enums.ChatGPTModel;
import com.zt.chatgpt.types.enums.OpenAiChannel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @author: zt
 * @Description: 聚合对象
 * @create: 2024-05-17 20:44
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ChatProcessAggregate {

    /** 用户id */
    private String openId;
    /** 默认模型 */
    private String model = ChatGPTModel.GPT_3_5_TURBO.getCode();
    /** 问题描述 */
    private List<MessageEntity> messages;

    /**
     * 验证用户是否是白名单
     */
    public boolean isWhiteList(String whiteListStr) {
        String[] whiteList = whiteListStr.split(Constants.SPLIT);
        for (String whiteOpenId : whiteList) {
            if (whiteOpenId.equals(openId)) {
                return true;
            }
        }
        return false;
    }

    public OpenAiChannel getChannel(){
        return OpenAiChannel.getChannel(this.model);
    }
}
